package com.hongyun.tms.common.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 费率贸别枚举
 * <p>
 * J进 C出
 *
 * @author peng.li
 * @date 2024-09-12
 */
@Getter
public enum ProdPlanEnum {
    COME("J", "进"),
    OUT("C", "出"),
    LOAD("Z", "装"),
    UNINSTALL("X", "卸"),

    WAIT_APPROVE("0", "待审"),
    APPROVED("1", "已审"),
    FEE("2", "已计费"),
    FINISH_WORK("3", "已完工"),
    REPEAT_APPROVE("4", "已复核");

    private final String code;
    private final String desc;

    ProdPlanEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ProdPlanEnum fromCode(String code) {
        for (ProdPlanEnum status : ProdPlanEnum.values()) {
            if (Objects.equals(status.getCode(), code)) {
                return status;
            }
        }
        return null;
    }

    public static String getCodeByDesc(String desc) {
        ProdPlanEnum[] tugStatusEnums = values();
        for (ProdPlanEnum tugStatusEnum : tugStatusEnums) {
            if (tugStatusEnum.getDesc().equals(desc)) {
                return tugStatusEnum.getCode();
            }
        }
        return null;
    }
}
